package com.google.codejam.qua2013.Lawnmower;

import java.util.Comparator;

public class MyComparator implements Comparator<Object> {

    public int compare(Object o1, Object o2) {
        SquareUnit p1 = (SquareUnit) o1;
        SquareUnit p2 = (SquareUnit) o2;
        if (p1.grassLenght == p2.grassLenght) {
            if (p1.indexN == p2.indexN) {
                return p1.indexM - p2.indexM;
            } else {
                return p1.indexN - p2.indexN;
            }
        } else {
            return p1.grassLenght - p2.grassLenght;
        }

    }
}
